package com.realone.packman.codec.decoder;

import com.realone.packman.codec.BmsCodecConstant;

/**
 * 解码工厂
 *
 * @author hugx
 * @create 2018-09-13 13:56
 */
public class BmsDecoderStrategyFacotry {

    public static BmsDecoderStrategy createBmsDecoderStrategy(short command) {
        BmsDecoderStrategy bmsDecoderStrategy = null;
        short commandTmp = command;
        if (command >= 0x20 && command <= 0x2F) {
            command = 0x20;
        }

        switch (command) {
            case BmsCodecConstant.Res_Cmd_0x10:
                bmsDecoderStrategy = new BmsDecoder10((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x11:
                bmsDecoderStrategy = new BmsDecoder11((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x12:
                bmsDecoderStrategy = new BmsDecoder12((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x13:
                bmsDecoderStrategy = new BmsDecoder13((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x14:
                bmsDecoderStrategy = new BmsDecoder14((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x15:
                bmsDecoderStrategy = new BmsDecoder15((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x16:
                bmsDecoderStrategy = new BmsDecoder16((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x17:
                bmsDecoderStrategy = new BmsDecoder17((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x18:
                bmsDecoderStrategy = new BmsDecoder18((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x19:
                bmsDecoderStrategy = new BmsDecoder19((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x1a:
                bmsDecoderStrategy = new BmsDecoder1a((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x1b:
                bmsDecoderStrategy = new BmsDecoder1b((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x1c:
                bmsDecoderStrategy = new BmsDecoder1c((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x1d:
                bmsDecoderStrategy = new BmsDecoder1d((int) command);
                break;
            case BmsCodecConstant.Res_Cmd_0x20:
                bmsDecoderStrategy = new BmsDecoderWarning((int) commandTmp);
                break;

            case BmsCodecConstant.Res_Cmd_0xFF:
                bmsDecoderStrategy = new BmsDecoderFf((int) command);
                break;

        }

        return bmsDecoderStrategy;
    }


}
